package karaokit.com;

import karaokit.com.KaraoKitEngine.SearchType;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

/**
 * this is the main class of the app. it runs the main menu
 * and manipulates the user's choice.
 *
 */
public class karaokit extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.e("In Main onCreate","In Main onCreate");
		System.out.println("In Main onCreate");
		setContentView(R.layout.income_screen);
		
		// Set up click listeners for all the buttons
		View playB = this.findViewById(R.id.PlayButton);
		playB.setOnClickListener(this);
		
		View browseB = this.findViewById(R.id.BrowsButton);
		browseB.setOnClickListener(this);

		View searchB = this.findViewById(R.id.SearchButton);
		searchB.setOnClickListener(this);
		
		View aboutB = this.findViewById(R.id.AboutButton);
		aboutB.setOnClickListener(this);

		View exitB = this.findViewById(R.id.ExitButton);
		exitB.setOnClickListener(this);	
	}

	public void onClick(View v) {
		Log.e("In Main onClick","");
		switch (v.getId()) {
		case R.id.PlayButton:
			if (!KaraoKitEngine.GetEngine().isMediaFileLoaded()) 
				Toast.makeText(this, "No file is currently loaded.\nTry 'Browse' or 'Search' first.", Toast.LENGTH_LONG).show();			
			else 
				KaraoKitEngine.GetEngine().loadSong(this, KaraoKitEngine.GetEngine().getCurMediaFile());
			break;			
		case R.id.BrowsButton:
			KaraoKitEngine.GetEngine().startBrowse(this, SearchType.Media);
			break;
		case R.id.SearchButton:			
			KaraoKitEngine.GetEngine().startSearch(this);
			break;
		case R.id.AboutButton:
			KaraoKitEngine.GetEngine().startAbout(this);
			break;
		case R.id.ExitButton: 
			finish();
		}
	}

}